/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nextel.project.util;

import com.nextel.ui.OLabel;
import com.nextel.ui.OSoftKey;
import com.nextel.ui.OUILook;
//import javax.microedition.lcdui.Command;
//import javax.microedition.lcdui.Displayable;
//import javax.microedition.lcdui.Font;
//import javax.microedition.lcdui.Form;
//import javax.microedition.lcdui.Spacer;
//import javax.microedition.lcdui.StringItem;
import pe.com.nextel.main.MVCAction;
//import pe.com.nextel.main.MVCComponent;



/**
 *
 * @author eespinoza
 */
public abstract class MVCBasic extends MVCAction {

   // protected Form form;
    private OLabel str;
    private OSoftKey cmdSeguir, cmdAtras;
    private String tituloForm;
    private String backtitulo;
    private String siguetitulo;
    protected boolean flagForm; // para que no presione dos veces al momento de buscar


    public MVCBasic(  String titulo, String nameSigue, String nameback) {

        this.tituloForm = titulo;
        this.backtitulo = nameback;
        this.siguetitulo = nameSigue;
    }


    protected void createView()  {

        cmdSeguir = new OSoftKey(siguetitulo);
        cmdAtras = new OSoftKey(backtitulo);


        formulario.setTitle("tituloForm", OUILook.PLAIN_SMALL_TITLE);

        formulario.addSoftKey(cmdSeguir);
        formulario.addSoftKey(cmdAtras);



    }

    protected void createItems() {

        StringBuffer stf = new StringBuffer();
        stf.append("").append(getMensaje()).append('\n');
        //str = new OLabel("", getMensaje());
        //str.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL));
        str = new OLabel(stf.toString(),OUILook.PLAIN_SMALL_TITLE);

        formulario.add(str);
        
        flagForm = true;

    }

    protected void updateView() throws Exception {
        destroy();
        createItems();
    }

  public void performAction(OSoftKey c) {

        if (flagForm) {


            if (c == cmdSeguir) {
                flagForm = false;
                destroy();
                seguir();


            } else if (c == cmdAtras) {
                flagForm = false;
                destroy();
                atras();

            }

        }
    }

    public abstract void seguir();

    public abstract void atras();

    public abstract String getMensaje();
}

